package math.base;

/**
 * @author Saga
 *
 */
public class CCS3d {
    public CCS3d() {
        this.origin = new Point3d(0.0, 0.0, 0.0);
        this.directX = new Dir3d();
        this.directY = new Dir3d();
        this.directZ = new Dir3d();

        this.directY.setNormalizedCoord(0.0, 1.0, 0.0);
        this.directY.setNormalizedCoord(0.0, 0.0, 1.0);
    }

    public CCS3d(final Point3d _origin, final Dir3d _dz, final Dir3d _dx) {
        this.origin = _origin;
        this.directZ = _dz;
        this.directY = new Dir3d(_dz.getCoord().crossed(_dx.getCoord()));
        this.directX = new Dir3d(this.directY.getCoord().crossed(_dx.getCoord()));
    }

    public final void setOrigin(final Point3d _origin) {
        this.origin = _origin;
    }

    public final Point3d getOrigin() {
        return this.origin;
    }

    public final Dir3d getDirectX() {
        return this.directX;
    }

    public final Dir3d getDirectY() {
        return this.directY;
    }

    public final Dir3d getDirectZ() {
        return this.directZ;
    }

    public final void xReverse() {
        this.directX.reverse();
    }

    public final CCS3d xReversed() {
        final CCS3d output = new CCS3d();
        output.origin = this.origin;
        output.directX = this.directX.reversed();
        output.directY = this.directY;
        output.directZ = this.directZ;

        return output;
    }

    public final void yReverse() {
        this.directY.reverse();
    }

    public final CCS3d yReversed() {
        final CCS3d output = new CCS3d();
        output.origin = this.origin;
        output.directX = this.directX;
        output.directY = this.directY.reversed();
        output.directZ = this.directZ;

        return output;
    }

    public final void zReverse() {
        this.directZ.reverse();
    }

    public final CCS3d zReversed() {
        final CCS3d output = new CCS3d();
        output.origin = this.origin;
        output.directX = this.directX;
        output.directY = this.directY;
        output.directZ = this.directZ.reversed();

        return output;
    }


    @Override
    public CCS3d clone() {
        final CCS3d output = new CCS3d();
        output.origin = this.origin.clone();
        output.directX = this.directX.clone();
        output.directY = this.directY.clone();
        output.directZ = this.directZ.clone();

        return output;
    }

    private Point3d origin;
    private Dir3d directX;
    private Dir3d directY;
    private Dir3d directZ;
}
